<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Vue中的动画原理</title>
    <style>
        .fade-enter,.fade-leave-to {
            opacity: 0;
        }

        .fade-enter-active,.fade-leave-active {
            transition: opacity .8s;
        }
    </style>
</head>

<body>
    <div id="root">
        <!-- 添加动画效果 -->
        <transition name="fade">
            <div v-if="show">hello world</div>
        </transition>
        <button @click="handleClick">切换</button>
    </div>
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
    <script>
        var vm = new Vue({
            el: "#root",
            data: {
                show: true
            },
            methods: {
                handleClick: function () {
                    this.show = !this.show;
                }
            }
        })
    </script>
</body>

</html>